package com.cy.ppj.service.wj.impl;

import com.cy.ppj.comm.utils.CommonUtils;
import com.cy.ppj.dao.mapper.wj.WjOrderMapper;
import com.cy.ppj.model.PageBean;
import com.cy.ppj.model.query.wj.WjOrderAdminListQuery;
import com.cy.ppj.model.vo.wj.WjOrderAdminListVO;
import com.cy.ppj.service.BaseService;
import com.cy.ppj.service.wj.WjOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description 万家分期订单 service
 * @Author tanyilin
 * @Date 2019/5/13 14:21
 */
@Service
public class WjOrderServiceImpl extends BaseService implements WjOrderService {

    @Autowired
    private WjOrderMapper wjOrderMapper;

    @Override
    public PageBean<WjOrderAdminListVO> selectWjOrderAdminList(WjOrderAdminListQuery query) {

        int total = wjOrderMapper.selectWjOrderAdminListCount(query);
        List<WjOrderAdminListVO> list = new ArrayList<>();
        if(total > 0) {
            query.startPage();
            list = wjOrderMapper.selectWjOrderAdminList(query);
            list.stream().forEach(w -> {
                w.setIdNo(CommonUtils.idNoFormat(w.getIdNo(), 6, 4));
            });
        }
        return new PageBean<>(list, total);
    }

}
